package cj.web.sc.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.sc.domain.SCCrowdFundOrder;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCCrowdFundOrderDAO{
	
	@SQL("select g.name as gameName,a.*,i.goodsItemName from SCCrowdFundOrder a JOIN SCCrowdFundOrderItems i ON a.id=i.orderId  JOIN Game g ON a.gameId=g.id WHERE a.deleteFlag=1 #if(:t.status!=-1){ AND a.status=:t.status } #if(:t.gameName!=''){ AND g.name LIKE '%##(:t.gameName)%' } #if(:t.memo!=''){ AND a.memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=''){ AND a.receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=''){ AND a.receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=''){ AND a.orderNo LIKE '%##(:t.orderNo)%' } #if(:t.code!=''){ AND a.code LIKE '%##(:t.code)%' } #if(:t.goodsItemName!=''){ AND i.goodsItemName LIKE '%##(:t.goodsItemName)%' } order by a.status desc,a.createAt desc limit :t.start,:t.length")
    List<SCCrowdFundOrder> query(@SQLParam("t") SCCrowdFundOrder sCCrowdFundOrder);
    
	@SQL("select count(0) from SCCrowdFundOrder a JOIN SCCrowdFundOrderItems i ON a.id=i.orderId  JOIN Game g ON a.gameId=g.id WHERE a.deleteFlag=1 #if(:t.status!=-1){ AND a.status=:t.status } #if(:t.gameName!=''){ AND g.name LIKE '%##(:t.gameName)%' } #if(:t.memo!=''){ AND a.memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=''){ AND a.receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=''){ AND a.receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=''){ AND a.orderNo LIKE '%##(:t.orderNo)%' } #if(:t.code!=''){ AND a.code LIKE '%##(:t.code)%' } #if(:t.goodsItemName!=''){ AND i.goodsItemName LIKE '%##(:t.goodsItemName)%' }")
	int size(@SQLParam("t")SCCrowdFundOrder sCCrowdFundOrder);
	
    @SQL("select * from SCCrowdFundOrder where id=:1")
    SCCrowdFundOrder queryById(int id);
    
    @SQL("INSERT INTO SCCrowdFundOrder ("
    		        		+ "id,"
			        		+ "buyerId,"
			        		+ "sellerId,"
			        		+ "sellerName,"
			        		+ "sellerLogo,"
			        		+ "orderNo,"
			        		+ "wxTradeNo,"
			        		+ "orginPrice,"
			        		+ "discntPrice,"
			        		+ "receiverName,"
			        		+ "receiverPhone,"
			        		+ "receiverAddress,"
			        		+ "isInvoice,"
			        		+ "invoiceHead,"
			        		+ "memo,"
			        		+ "expressCom,"
			        		+ "expressBill,"
			        		+ "status,"
			        		+ "payWay,"
			        		+ "gameId,"
			        		+ "code,"
			        		+ "payAt,"
			        		+ "exportFlag,"
			        		+ "deleteFlag,"
			        		+ "createAt,"
			        		+ "createUser,"
			        		+ "updateAt,"
			        		+ "updateUser,"
							+") VALUES ("
							+ ":t.id,"
							+ ":t.buyerId,"
							+ ":t.sellerId,"
							+ ":t.sellerName,"
							+ ":t.sellerLogo,"
							+ ":t.orderNo,"
							+ ":t.wxTradeNo,"
							+ ":t.orginPrice,"
							+ ":t.discntPrice,"
							+ ":t.receiverName,"
							+ ":t.receiverPhone,"
							+ ":t.receiverAddress,"
							+ ":t.isInvoice,"
							+ ":t.invoiceHead,"
							+ ":t.memo,"
							+ ":t.expressCom,"
							+ ":t.expressBill,"
							+ ":t.status,"
							+ ":t.payWay,"
							+ ":t.gameId,"
							+ ":t.code,"
							+ ":t.payAt,"
							+ ":t.exportFlag,"
							+ ":t.deleteFlag,"
							+ ":t.createAt,"
							+ ":t.createUser,"
							+ ":t.updateAt,"
							+ ":t.updateUser,"
					+")")
    void create(@SQLParam("t") SCCrowdFundOrder sCCrowdFundOrder);
	
	@SQL("UPDATE SCCrowdFundOrder SET "
		    		    						    			        + "buyerId=:t.buyerId,"
		        					    			        + "sellerId=:t.sellerId,"
		        					    			        + "sellerName=:t.sellerName,"
		        					    			        + "sellerLogo=:t.sellerLogo,"
		        					    			        + "orderNo=:t.orderNo,"
		        					    			        + "wxTradeNo=:t.wxTradeNo,"
		        					    			        + "orginPrice=:t.orginPrice,"
		        					    			        + "discntPrice=:t.discntPrice,"
		        					    			        + "receiverName=:t.receiverName,"
		        					    			        + "receiverPhone=:t.receiverPhone,"
		        					    			        + "receiverAddress=:t.receiverAddress,"
		        					    			        + "isInvoice=:t.isInvoice,"
		        					    			        + "invoiceHead=:t.invoiceHead,"
		        					    			        + "memo=:t.memo,"
		        					    			        + "expressCom=:t.expressCom,"
		        					    			        + "expressBill=:t.expressBill,"
		        					    			        + "status=:t.status,"
		        					    			        + "payWay=:t.payWay,"
		        					    			        + "gameId=:t.gameId,"
		        					    			        + "code=:t.code,"
		        					    			        + "payAt=:t.payAt,"
		        					    			        + "exportFlag=:t.exportFlag,"
		        					    			        + "deleteFlag=:t.deleteFlag,"
		        					    			        + "createAt=:t.createAt,"
		        					    			        + "createUser=:t.createUser,"
		        					    			        + "updateAt=:t.updateAt,"
		        					    			        + "updateUser=:t.updateUser,"
		        						+ " WHERE id=:t.id")
    void update(@SQLParam("t") SCCrowdFundOrder sCCrowdFundOrder);
    
    @SQL("UPDATE SCCrowdFundOrder SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("UPDATE SCCrowdFundOrder SET deleteFlag=0,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
	void delete(@SQLParam("t")SCCrowdFundOrder order);

    @SQL("UPDATE SCCrowdFundOrder SET progress=:2 WHERE id=:1")
	void mutiUpdateProgress(List<Integer> ids, String progress);

    @SQL("select g.name as gameName,i.goodsItemName as itemDetails,a.expressBill,a.sellerName,a.orderNo,a.discntPrice,a.receiverName,a.receiverPhone,a.receiverAddress,a.memo,a.status,a.payWay,a.code,a.progress,a.wxTradeNo,a.payAt from SCCrowdFundOrder a JOIN SCCrowdFundOrderItems i ON a.id=i.orderId  JOIN Game g ON a.gameId=g.id WHERE a.deleteFlag=1 #if(:t.status!=-1){ AND a.status=:t.status } #if(:t.gameName!=''){ AND g.name LIKE '%##(:t.gameName)%' } #if(:t.memo!=''){ AND a.memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=''){ AND a.receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=''){ AND a.receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=''){ AND a.orderNo LIKE '%##(:t.orderNo)%' } #if(:t.code!=''){ AND a.code LIKE '%##(:t.code)%' } #if(:t.goodsItemName!=''){ AND i.goodsItemName LIKE '%##(:t.goodsItemName)%' } order by a.status desc,a.createAt desc")
	List<Map> output(@SQLParam("t")SCCrowdFundOrder order);

	
}